package com.nogroup.springbootproject.service.impl;

import com.alibaba.fastjson.JSON;
import com.nogroup.springbootproject.entity.Authority;
import com.nogroup.springbootproject.service.AuthorityService;
import com.nogroup.springbootproject.service.LoginService;
import com.nogroup.springbootproject.vo.LoginUserVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;


@Service("loginService")
@Transactional(rollbackFor = Exception.class)
public class LoginServiceImpl implements LoginService {

    @Autowired
    private AuthorityService authorityService;


    @Override
    public LoginUserVo loginUser(Authority authority) {
        Authority loginUser = authorityService.loginUser(authority);
        if(null != loginUser){
            LoginUserVo loginUserVo = new LoginUserVo();
            loginUserVo.setAuthority(loginUser);
            System.out.println("Username:" + loginUser.getAuthorityUsername());
            System.out.println("password:" + loginUser.getAuthorityPassword());
            return loginUserVo;
        }else {
            return null;
        }
    }
}
